package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class test
{
    /*public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username=sc.next();
        System.out.println("请输入密码：");
        String password=sc.next();
        try(Connection con=DButil.getConnection();)
        {
            Statement sa=con.createStatement();
            String sql="SELECT ID,USERNAME,PASSWORD,NICKNAME FROM USER WHERE NAME='"+username+"' AND PASSWORD='"+password+"'";
            ResultSet re=sa.executeQuery(sql);
            if(re.next())
            {
                System.out.println("登录成功");
            }
            else
            {
                System.out.println("登录失败");
            }

        } catch (SQLException e) {e.printStackTrace();}
    }

     */
    public static void main(String[] args)
    {
        try (Connection con=DButil.getConnection();)
        {
            Statement sa=con.createStatement();
            String sql="SELECT S.NAME FROM STUDENT S JOIN CLASS C ON C.ID=S.CLASS_ID "
                      +"JOIN TEACHER T ON C.TEACHER_ID=T.ID "
                      +"WHERE T.SALARY>10000 AND S.JOB= '大队长'";
            ResultSet re=sa.executeQuery(sql);
            while(re.next())
            {
                String name=re.getString("S.NAME");
                System.out.println(name);
            }
        } catch (SQLException e) {e.printStackTrace();}
    }
}
